package com.lagou.controller;

import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ArticleController {


    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String toLoginPage(@RequestParam(value = "pageNum", defaultValue = "0") Integer pageNum,  @RequestParam(value = "pageSize", defaultValue = "2") Integer pageSize, Model model){

        System.out.println("pageNum:"+pageNum);
        System.out.println("pageSize:"+pageSize);
        Page<Article> page = articleService.findByPage(pageNum, pageSize);
        model.addAttribute("page",page);

        return "client/index";
    }




}
